﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:import href="../Common/meta.xsl"/>
  <xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>
  <xsl:param name="lang" select="'chi'"></xsl:param>
  <xsl:variable name="headers" select="document('headers.xml')//header[@lang=$lang]"></xsl:variable>
    <xsl:template match="/">
      <xsl:variable name="jobNodes" select="recruitment/job"></xsl:variable>
      <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
          <title>
            <xsl:value-of select="$headers/title"/>
          </title>
          <xsl:call-template name="content-lang"></xsl:call-template>
          <xsl:call-template name="css"></xsl:call-template>
          <xsl:call-template name="script"></xsl:call-template>
          <script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
          <script type="text/javascript">
            var pageTracker = _gat._getTracker("UA-3662766-1");
            pageTracker._initData();
            pageTracker._trackPageview();
          </script>
        </head>
        <body>
          <div id="Recruitment">
            <xsl:choose>
              <xsl:when test="count($jobNodes)&lt;2">
                <p>
                  <xsl:value-of select ="recruitment/job[@reference='N/A']/notice[@lang=$lang]"/>
                </p>
              </xsl:when>
              <xsl:when test="$lang='eng'">
                <p>
                  Please refer to the <a href="/chi/general/recruitment.html" target="_parent">Chinese</a> or <a href="/por/general/recruitment.html" target="_parent">Portuguese</a> version. Thank you.
                </p>
              </xsl:when>
              <xsl:otherwise>
                <dl>
                  <xsl:for-each select="recruitment/job[@reference!='N/A']">
                    <dt>
                      <xsl:value-of select="name[@lang=$lang]"/>
                    </dt>
                    <xsl:for-each select="notice">
                      <dd>
                        <a>
                          <xsl:attribute name="href">
                            <xsl:value-of select="file[@lang=$lang]"/>
                          </xsl:attribute>
                          <xsl:attribute name="target">
                            <xsl:value-of select="file[@lang=$lang]/@target"/>
                          </xsl:attribute>
                          <xsl:value-of select="title[@lang=$lang]"/> 
                        </a>
                        (<xsl:value-of select="./@day"/>/<xsl:value-of select="./@month"/>/<xsl:value-of select="./@year"/>)
                      </dd>
                    </xsl:for-each>
                  </xsl:for-each>
                </dl>
              </xsl:otherwise>
            </xsl:choose>
          </div>
        </body>
      </html>
    </xsl:template>

  <xsl:template name="css">
    <xsl:for-each select="$headers/css">
      <link rel="stylesheet" type="text/css">
        <xsl:attribute name="media">
          <xsl:value-of select="@media"/>
        </xsl:attribute>
        <xsl:attribute name="href">
          <xsl:value-of select="."/>
        </xsl:attribute>
      </link>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="script">
    <xsl:for-each select="$headers/script"> 
      <script>
        <xsl:attribute name="type">
          <xsl:value-of select="@type"/>
        </xsl:attribute>
        <xsl:attribute name="src">
          <xsl:value-of select="."/>
        </xsl:attribute>
      </script>
    </xsl:for-each>
  </xsl:template>
  
</xsl:stylesheet>
